#include <bits/stdc++.h>
#define rep(i,l,r) for (int i = l; i <= r; i ++)
#define per(i,r,l) for (int i = r; i >= l; i --)
using namespace std;
const int MN = 1e5 + 5;
int N,Q,Seq[MN],Pos[MN],MP[MN],Arr[MN];
int a[MN],b[MN];
inline void Del (int x) {
	rep (i,x,N - 1) a[i] = Seq[i + 1],b[i] = Pos[i + 1];
	rep (i,x,N - 1) Seq[i] = a[i],Pos[i] = b[i],MP[b[i]] = i;
}
inline void Ins (int x,int M) {
	int opt = 0,tmp = Arr[x];
	rep (i,1,M - 1) if (tmp < Seq[i] || Seq[i] == tmp && x < Pos[i]) {
		opt = i; break ;
	}
	if (opt == 0) opt = M;
	rep (i,opt + 1,M) a[i] = Seq[i - 1],b[i] = Pos[i - 1];
	per (i,M,opt + 1) Seq[i] = a[i],Pos[i] = b[i],MP[b[i]] = i;
	Seq[opt] = tmp,Pos[opt] = x,MP[x] = opt;
}
int main () {
	freopen ("sort.in","r",stdin);
	freopen ("sort.out","w",stdout);
	scanf ("%d%d",&N,&Q);
	rep (i,1,N) {
		scanf ("%d",&Arr[i]); Ins (i,i);
	}
	while (Q --) {
		int opt; scanf ("%d",&opt);
		if (opt == 1) {
			int x,val; scanf ("%d%d",&x,&val);
			Arr[x] = val,Del (MP[x]),Ins (x,N);
		}
		if (opt == 2) {
			int x; scanf ("%d",&x);
			printf ("%d\n",MP[x]);
		}
	}
	return 0;
}

